package concurrence.lock;

public class SynchronizedReentrantLockDemo {
    public static void main(String[] args) {
        Phone phone = new Phone();//共享资源
        new Thread(new Runnable() {//线程1
            @Override
            public void run() {
                phone.sendSMS();
            }
        }).start();

        new Thread(()->{//线程2
            phone.sendSMS();
        }).start();

    }
}
class Phone{
    public synchronized void sendSMS() {
        sendEmail();
        System.out.println(Thread.currentThread().getName()+"sendSMS");
    }
    public synchronized void sendEmail() {
        System.out.println(Thread.currentThread().getName()+"sendEmail");

    }
}
